<?php 
require_once("../connect_db.php");
$sqlTeacher="select teach_id,teach_name,teach_lname from teacher where status!='N'";
$queryTeacher=mysql_query($sqlTeacher);
?>

<form method="post" enctype="multipart/form-data" name="frmreg" id="frmreg">

<div class="row">
	<div class="col-md-12">
		<div class="panel">
		 
		  <div class="panel-body">
		  <div style="float:right;padding-bottom:20px;">
		  <button type="button" class="btn btn-success nav_link2" txt="เพิ่มข้อมูลผู้สอน" url="admin/insert_Teacher_page.php"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span>&nbsp;เพิ่มผู้สอน</button>
		
		  </div>
		  
			<table cellpadding="0" cellspacing="0" border="0" class="display" id="Teacher" width="100%" style="font-size:14px">
	<thead>
		<tr>
		
			<th style="width:40%;text-align: center !important;color:black; !important;font-size:1em">ชื่อ - นามสกุล</th>
			<th style="width:20%;text-align: center !important;color:black; !important;font-size:1em">รายละเอียด</th>
			<th style="width:20%;text-align: center !important;color:black; !important;font-size:1em">ตารางสอน</th>
			<th style="width:20%;text-align: center !important;color:black; !important;font-size:1em">แก้ไข</th>
			<th style="width:20%;text-align: center !important;color:black; !important;font-size:1em">ลบ</th>
		</tr>
	</thead>
	<tbody style="color:black !important;">
	
		<?php while($resultTeacher=mysql_fetch_array($queryTeacher)){?>
		<tr>
			<td style="text-align: center !important;color:black; !important;font-size:1em"><?php echo $resultTeacher["teach_name"]." ".$resultTeacher["teach_lname"]?></td>
			<td style="text-align: center !important;color:black; !important;font-size:1em">
			<img class="popup_window pics" temp="<?php echo $resultTeacher["teach_id"]?>"  src="../pic/info.png" width="50" />
			</td>
			<td style="text-align: center !important;color:black; !important;font-size:1em">
			<img class="popup_window2 pics" temp="<?php echo $resultTeacher["teach_id"]?>"  src="../pic/calendar.png" width="50" />
			</td>
			<td style="text-align: center !important;color:black; !important;font-size:1em">
			<img class="pics nav_link2" txt="แก้ไขข้อมูลผู้สอน" url="admin/insert_teacher_page.php?temp=<?php echo $resultTeacher["teach_id"] ?>" src="../pic/edit.png" width="50" />
			</td>
			<td style="text-align: center !important;color:black; !important;font-size:1em">
			<img class="pics"  src="../pic/delete.png" width="50"
			onClick="if(window.confirm('ต้องการลบกรุณายืนยัน'))
			{$('#mainscreen').load('admin/delete_page.php?temp=<?php echo $resultTeacher["teach_id"]."&role=2"?>');} " 
			/>
			</td>
		</tr>
		<?php }?>
	</tbody>
	
</table>
		  </div>
		</div>
	</div>
</div>
</div>

 
<div id="data-popup" class="popup">
    <div class="popup-body"><span class="popup-exit"></span>
 
        <div class="popup-content">
            <h2 class="popup-title">ข้อมูลผู้สอน</h2>
			<div class="popup-des">
			<img class="pics" src="../pic/bx_loader.gif" width="50" />
			</div>
        </div>
    </div>
</div>
<div id="data-popup2" class="popup" style="top:8%;">
    <div class="popup-body"><span class="popup-exit"></span>
 
        <div class="popup-content">
            <h2 class="popup-title">ตารางสอน</h2>
			<div class="popup-des pop2" >
			
			<div id='calendar' style="display:none;"></div>
			
			</div>
        </div>
    </div>
</div>
<div class="popup-overlay"></div>
</form>
<script>
$(document).ready(function(){
$(".nav_link2").click(function(e){
				$("#h3title").html($(this).attr("txt"));
				$("#mainscreen").load($(this).attr("url"));
				return false;
			});
  	oTable = $('#Teacher').dataTable({
          "bJQueryUI": true,
          "sPaginationType": "full_numbers"
      });

$('.popup_window').click(function () {
        $('html').addClass('overlay');
        var activePopup = "#data-popup";
        $(activePopup).addClass('visible');
		 $('.popup-overlay').click(function () {
        clearPopup();
		});
		$.ajax({
		url:"admin/preview_data.php?type="+2+"&temp="+$(this).attr("temp"),
			success:function(res){
			$(".popup-des").html(res);
			 $('.popup-exit').click(function () {
				clearPopup();
				});
			}
		});
 
    });
	
	
		$('.popup_window2').click(function () {
	$(".pop2").html('');
	$(".pop2").html('<img class="pics imgload" src="../pic/bx_loader.gif"  width="50" /><div id="calendar" style="display:none;"></div>');
        $('html').addClass('overlay');
        var activePopup = "#data-popup2";
        $(activePopup).addClass('visible');
		 $('.popup-overlay').click(function () {
        clearPopup();
		});
		$.ajax({
				url:"admin_teacher_calendar_json.php?temp="+$(this).attr("temp"),
				success:function(resp){
				setTimeout(function(){ 
				$(".imgload").remove();
			$('#calendar').show();
			$('#calendar').fullCalendar({
			header: {
				left: 'prev,next today',
				center: 'title',
				right: 'month,agendaWeek,agendaDay'
			},
			defaultDate: '2015-01-1',
			businessHours: true, // display business hours
			editable: false,
			events:"json/admin_teacher_events.json"
		});
}, 2500);

}
});

    });
	
	
 
    $(document).keyup(function (e) {
        if (e.keyCode == 27 && $('html').hasClass('overlay')) {
            clearPopup();
        }
    });
 
      
 
});
	  
	
	 function clearPopup() {
        $('.popup.visible').addClass('transitioning').removeClass('visible');
        $('html').removeClass('overlay');
 
        setTimeout(function () {
            $('.popup').removeClass('transitioning');
        }, 200);
    }
</script>